package com.aistar.service.impl;

import com.aistar.mapper.AnswerMapper;
import com.aistar.pojo.Answer;
import com.aistar.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AnswerServiceImpl implements AnswerService {
    @Autowired
    private AnswerMapper answerMapper;

    @Override
    public Answer getById(Integer id) {
        return answerMapper.selectByPrimaryKey(id);

    }

    @Override
    public List<Answer> getByQuestionId(Integer id) {
        List<Answer> answerList=answerMapper.selectByExampleWithBLOBs(null);
        List<Answer> answers=new ArrayList<>();
        for(Answer a: answerList){
            if(a.getAnsQueId() == id){
                answers.add(a);
            }
        }

        return answers;
    }
}
